
		**********************************************************
		** File: Figures_C1-C12.do								**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Creating C1-C12 maps							**
 		**********************************************************
		
	clear all
	version 16.1
	set seed 1234

	set scheme lean1
	graph set window fontface "Times New Roman"

	cd "~/"
	
	use "HTI 00-17.dta", clear
	
	sort ccode year
	
	drop if ccode==-11
	drop if ccode==-22
	drop if ccode==-33
	drop if ccode==0
	
	** DRC was not coded for 2014-2017. I checked coding for 2017 which was almost
	** identical to 2013. Therefore using 2013 values now and will go back and
	** add to data later.
	replace year=2017 if ccode==490 & year==2013 
	 replace enforcement=1 if ccode==490  
	keep if year==2017
	sort ccode year
	duplicates report ccode year
 

	keep country ccode source transit destination psource ptransit pdest pinternal ///
		lsource ltransit ldest linternal domesticlaws enforcement convictinfo ///
		victimid victimservices victimpunish preventprogress progress protocol
	
	save "hti_2017_for_maps.dta", replace

	use "/Users/rich/Dropbox/Data/GIS data/spmap/idfile.dta", clear
	rename ccode QOScode
	
	sort COWcode
	rename COWcode ccode
	drop if ccode==.
	merge m:1 ccode using "hti_2017_for_maps.dta"
	browse if _merge==1
	drop _merge
 
	replace enforce=0 if enforce==-1

	***********************
	*** CREATING GRAPHS ***
	***********************
	
	
	** Domestic laws 
	spmap domesticla ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)       
		graph save dom_laws.gph, replace
	 
	** ENFORCEMENT **
	spmap enforcement ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1.5 2)
		graph save enforce.gph, replace
	
	** Victim identification **
	
	replace victimid=2 if victimid==1
	replace victimid=1 if victimid==0
	replace victimid=0 if victimid==-1
	
	spmap victimid ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1.5 2)
		graph save victimid.gph, replace
	
	** Victim services **
	
	replace victims=0 if victims==-1
 
	spmap victims ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save victims.gph, replace	
	
	** Victim punish **
	
	replace victimpunish=2 if victimpunish==1
	replace victimpunish=1 if victimpunish==0
	replace victimpunish=0 if victimpunish==-1
 
	spmap victimp ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1.5 2)
		graph save victimp.gph, replace
	
	** Protocol **
	
	replace victimpunish=2 if victimpunish==1
	replace victimpunish=1 if victimpunish==0
	replace victimpunish=0 if victimpunish==-1
 
	spmap victimp ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1.5 2)
		graph save victimp.gph, replace
	
	** convict info **
	
	replace convictinfo=2 if convictinfo==1
	replace convictinfo=1 if convictinfo==0
	replace convictinfo=0 if convictinfo==-1
 
	spmap convictinfo ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1.5 2)
		graph save convictinfo.gph, replace
	
		
	** psource **
	codebook psource
	
 	spmap psource ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save psource.gph, replace	
				
	** ptransit **
	codebook ptransit
	
 	spmap ptransit ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save ptransit.gph, replace	
				
	** pdest **
	codebook pdest
	
 	spmap pdest ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save pdest.gph, replace	
				

	** pinternal **
	codebook pinternal
	
 	spmap pinternal ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save pinternal.gph, replace	
		
	** linternal **
	codebook linternal
	
 	spmap linternal ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save linternal.gph, replace	
				
		
		
	** lsource **
	codebook lsource
	
 	spmap lsource ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save lsource.gph, replace	
				
	** ltransit **
	codebook ltransit
	
 	spmap ltransit ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save ltransit.gph, replace	
				
	** ldest **
	codebook ldest
	
 	spmap ldest ///
			using "/Users/rich/Dropbox/Data/GIS data/spmap/coord_mercator_world.dta", ///
			id(na_id_world)	osize(vvthin vvthin vvthin vvthin) ndsize(vvthin)   ///  
			clmethod(custom) clbreaks(  0 0.5  1 )
		graph save ldest.gph, replace	
				


	sort year
	by year: egen totalcountries=count(ccode)
	label var totalcountries "Total # countries in given year"


	run "/Users/rich/Dropbox/Data/GIS data/spmap/SPMAP ID to CCODE"
	merge m:1 id using "/Users/rich/Dropbox/Data/GIS data/spmap/worlddata.dta"
	rename ccode scow
	sort scow year
	save "HTI 00-17 for graphs.dta", replace
	
	keep if year==2017
	export delimited using "/Users/rich/Dropbox/research/ht/papers/HT data paper/data/HTI 17 for graphs.csv", replace

	
	
